Separate DB almost fixed
[RRRRHHHH_Code] / ruralHouses client / src / gui / ModifyOfferGUI.java
index 14dd98d..73230bb 100644 (file)
@@ -26,9 +26,9 @@ import javax.swing.JLabel;
 import javax.swing.JTextField;
 
 import com.toedter.calendar.JCalendar;
+
 import common.HouseInterface;
 import common.OfferInterface;
-
 import configuration.___IntNames;
 import domain.Offer;
 import domain.Owner;
@@ -89,7 +89,9 @@ public class ModifyOfferGUI extends JFrame {
                        Hlist = hm.getHouses(o, null, null, 0, 0, 0, 0, 0);
                } catch (RemoteException e1) {
                        e1.printStackTrace();
-               }               
+               }
+
+
                jComboBox1 = new JComboBox<RuralHouse>(Hlist);
 
                comboBox_o = new JComboBox<Offer>(
@@ -149,7 +151,6 @@ public class ModifyOfferGUI extends JFrame {
                                try {
                                        vo = om.getRuralHouseOffers((RuralHouse) jComboBox1.getSelectedItem());
                                } catch (RemoteException e) {
-                                       // TODO Auto-generated catch block
                                        e.printStackTrace();
                                }
                                comboBox_o.removeAllItems();
@@ -251,7 +252,28 @@ public class ModifyOfferGUI extends JFrame {
                                }
                        }
                });
-
+               if(((Offer) comboBox_o.getSelectedItem()).isBooked()){
+                       jLabel5.setText("This offer is already booked.");
+                       jButton1.setEnabled(false);                                     
+               }
+               comboBox_o.addItemListener(new ItemListener() {
+                       @Override
+                       public void itemStateChanged(ItemEvent arg0) {
+                               if(((Offer) comboBox_o.getSelectedItem()).isBooked()){
+                                       jLabel5.setText("This offer is already booked.");
+                                       jButton1.setEnabled(false);                                     
+                               }
+                       }
+               });
+               comboBox_o.addItemListener(new ItemListener() {
+                       @Override
+                       public void itemStateChanged(ItemEvent arg0) {
+                               if(!((Offer) comboBox_o.getSelectedItem()).isBooked()){
+                                       jLabel5.setText("");;
+                                       jButton1.setEnabled(true);                                      
+                               }
+                       }
+               });
                this.getContentPane().add(jCalendar2, null);
                this.getContentPane().add(jCalendar1, null);
                this.getContentPane().add(jLabel5, null);